<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8"/>
	<meta name="keywords" content="migration, specification change, line ending, line break"/>
	<link rel="stylesheet" href="../../Shared/sty/standard.css"/>
	<script defer src="../../Shared/js/toc.js"></script>
	
	<title>Important changes on CotEditor 4.2</title>
</head>

<body>
<a name="specification_changes_on_4.2.0"></a>

<h1>Important changes on CotEditor 4.2</h1>

<p>The way to handle line endings was changed in CotEditor 4.2.0, which was released in May 2022. Prior to version 4.2.0, all line ending codes were internally treated as LF (<code>U+000A</code>). From version 4.2.0, the actual line ending codes in document files are treated as they are. Therefore, users, especially those who have used earlier versions, require awareness of this change and may need manual migration for some settings.</p>
<p>For details on how the latest CotEditor treats line endings, see <a href="about_line_endings.html">Handle various types of line endings</a>.</p>


<section>
<h2>Line ending code in the regular expression pattern</h2>

<p>Because the previous CotEditor handled all line ending codes as LF internally, <code>\n</code> could be used in regular expression patterns to recognize newlines, regardless of the actual line endings in the document. From CotEditor 4.2.0 on, <code>\n</code> matches only the line endings of which document actually uses LF as the line ending. If you want your documents to match any line endings regardless of the line ending character, use <code>\R</code> instead of <code>\n</code>.</p>

<p class="addition"><code>\R</code> is the metacharacter defined in the <a href="about_regex.html">CUI regular expression engine</a>, which is used in CotEditor; and matches any of a newline character, such as <code>U+000A</code> (LF), <code>U+000B</code>, <code>U+000C</code>, <code>U+000D</code> (CR), <code>U+0085</code>, <code>U+2028</code>, <code>U+2029</code>, or the sequence of <code>U+000D</code> <code>U+000A</code> (CRLF).</p>
</section>


<section>
<h2>Line ending handling in user settings</h2>

<p>Scripts and regular expression patterns that assume only LF as line endings may not behave as intended in documents with other line endings than LF on CotEditor 4.2.0 and later. Those user settings require change by the user.</p>

<p>The following user settings require attention to the line ending handling:</p>
<ul>
	<li><p>Replacement definitions for the <a href="howto_multiple_replace.html">multiple replacements</a></p></li>
	<li><p><a href="syntax_highlight_settings.html">Custom definitions</a> in the syntax definitions</p></li>
	<li><p>The line ending handling in <a href="script_overview.html">user scripts</a> for the Script menu</p></li>
</ul>
</section>


<section>
<h2>Line endings in Find &amp; Replace</h2>

<p>In the normal textual search and replace, the line endings contain in the search or replace text are assumed as the same as the line ending code used in the document being searched for.</p>

<p>That is, for example, if you search a document in which the line endings are LF for the text containing the CR line ending as a (non-regular expression) text search, all line endings in the search text will be assumed as LF. If you want to handle line endings strictly on search, use the regular expression instead.</p>

<p>On the other hand, regarding the text replacing with, all line endings even ones defined as a metacharacter like <code>\r</code> are assumed as the document line ending. Currently, there is no way to replace with line endings other than the document line ending and this is the same behavior as the previous CotEditor.</p>

<p>See <a href="howto_find_newline.html">Find or replace a line ending</a> for the details of how CotEditor handles line endings in the Find &amp; Replace.</p>
</section>


<section id="cf">
<h2>See also</h2>
<ul>
	<li><a href="about_line_endings.html">Handle various types of line endings in CotEditor on Mac</a></li>
	<li><a href="howto_find_newline.html">Find or replace a line ending in CotEditor on Mac</a></li>
	<li><a href="howto_find_inconsistent_line_endings.html">Find inconsistent line endings in CotEditor on Mac</a></li>
	<li><a href="howto_paste.html">Paste text in CotEditor on Mac</a></li>
	<li><a href="whats_new_in_4.2.html">What’s new in CotEditor 4.2?</a></li>
	<li><a href="releasenotes.html">Release notes for CotEditor on Mac</a></li>

</section>

</body>
</html>
